Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

457
Views
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/got/dist/source/index.js from /app/commands/Image/meme.js not supported

Code:

const { EmbedBuilder } = require("discord.js");
const got = require("got");

module.exports = {
  name: "meme",
  description: "Shows an image of a meme!",
  run: async (client, message, args) => {
      got("https://www.reddit.com/r/memes/random/.json").then(response => {
      const [list] = JSON.parse(response.body);
      const [post] = list.data.children;

      const permalink = post.data.permalink;
      const memeUrl = `https://reddit.com${post.data.permalink}`;
      const memeImage = post.data.url;
      const memeTitle = post.data.title;
      const memeUpvotes = post.data.ups;
      const memeNumComments = post.data.num_comments;
      
      const memeEmbed = new EmbedBuilder()
         .setTitle(`${memeTitle}`)
         .setURL(`${memeUrl}`)
         .setColor("Random")
         .setImage(memeImage)
         .setFooter({ text: `👍 ${memeUpvotes} | 💬 ${memeNumComments}` });
      message.reply({ embeds: [memeEmbed] });
    });
  }
};

Error:

const got = require("got");
            ^
Error [ERR_REQUIRE_ESM]: require() of ES Module

/app/node_modules/got/dist/source/index.js from /app/commands/Image/meme.js not supported.

I’m not too sure what this ESM is, I’ve never dealt with it before, therefore I don’t know what to do to fix this.

Kinda think it’s got to do something with the package itself, but like I said I’m clueless as I’ve never had this error before.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

got is a native ESM and no longer provides a CommonJS export.

Use ESM

To use the latest version, you'll have to convert to ESM:

  1. you need to add "type": "module" to your package.json
  2. replace all require()s and module.exports with import and export

Downgrade got

Another option is to downgrade got to v11.8.3 as it's pretty stable:

You can run npm i got@11.8.3 in your console.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!